home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / labele1a / labele~1.frm next >
Text File  |  1999-09-16  |  5KB  |  155 lines

  1. VERSION 5.00
  2. Begin VB.Form Form1 
  3.    Caption         =   "Label Edit Form"
  4.    ClientHeight    =   3420
  5.    ClientLeft      =   60
  6.    ClientTop       =   375
  7.    ClientWidth     =   4575
  8.    LinkTopic       =   "Form1"
  9.    ScaleHeight     =   3420
  10.    ScaleWidth      =   4575
  11.    StartUpPosition =   3  'Windows Default
  12.    Begin VB.CommandButton Command1 
  13.       Caption         =   "Stop"
  14.       Height          =   495
  15.       Left            =   1800
  16.       TabIndex        =   3
  17.       Top             =   2640
  18.       Width           =   1215
  19.    End
  20.    Begin VB.TextBox T1 
  21.       BackColor       =   &H00C0FFFF&
  22.       Height          =   285
  23.       Left            =   120
  24.       MaxLength       =   100
  25.       TabIndex        =   2
  26.       Top             =   2880
  27.       Width           =   1215
  28.    End
  29.    Begin VB.Label L1 
  30.       BackColor       =   &H80000009&
  31.       BorderStyle     =   1  'Fixed Single
  32.       Height          =   375
  33.       Index           =   4
  34.       Left            =   120
  35.       TabIndex        =   6
  36.       Top             =   2160
  37.       Width           =   4335
  38.       WordWrap        =   -1  'True
  39.    End
  40.    Begin VB.Label L1 
  41.       BackColor       =   &H80000009&
  42.       BorderStyle     =   1  'Fixed Single
  43.       Height          =   375
  44.       Index           =   3
  45.       Left            =   120
  46.       TabIndex        =   5
  47.       Top             =   1680
  48.       Width           =   4335
  49.       WordWrap        =   -1  'True
  50.    End
  51.    Begin VB.Label L1 
  52.       BackColor       =   &H80000009&
  53.       BorderStyle     =   1  'Fixed Single
  54.       Height          =   375
  55.       Index           =   2
  56.       Left            =   120
  57.       TabIndex        =   4
  58.       Top             =   1200
  59.       Width           =   4335
  60.       WordWrap        =   -1  'True
  61.    End
  62.    Begin VB.Label L1 
  63.       BackColor       =   &H80000009&
  64.       BorderStyle     =   1  'Fixed Single
  65.       Height          =   375
  66.       Index           =   1
  67.       Left            =   120
  68.       TabIndex        =   1
  69.       Top             =   720
  70.       UseMnemonic     =   0   'False
  71.       Width           =   4335
  72.       WordWrap        =   -1  'True
  73.    End
  74.    Begin VB.Label L1 
  75.       BackColor       =   &H80000009&
  76.       BorderStyle     =   1  'Fixed Single
  77.       Height          =   375
  78.       Index           =   0
  79.       Left            =   120
  80.       TabIndex        =   0
  81.       Top             =   240
  82.       Width           =   4335
  83.       WordWrap        =   -1  'True
  84.    End
  85. End
  86. Attribute VB_Name = "Form1"
  87. Attribute VB_GlobalNameSpace = False
  88. Attribute VB_Creatable = False
  89. Attribute VB_PredeclaredId = True
  90. Attribute VB_Exposed = False
  91. 'Label Editing  -   9-16-99
  92. 'Actually this code seems rather mundane, but it comes in
  93. 'really handy if you need to assign a lot of text to arrays
  94. 'for math manipulation then it is too clumsy to do it this
  95. 'way... arry(1)=val(text1.text)
  96. '       arry(2)=val(text2.text) etc.
  97. 'much better doing it with a 'For...Next' loop.
  98. 'or even only if you have a lot of TextBoxes
  99. 'There are 2 ways of doing this; with a Text1(x). Array
  100. 'or with a Label1(x). Array.
  101. 'The Text1(). Array carries to much baggage because of the
  102. 'intrinsic editing features. So...
  103. 'The Label1(). Array only requires 1 TextBox and you'll never
  104. 'know the difference, except that you cannot TAB to the next
  105. 'Label.
  106. 'To create an Array of Labels simply create Label1, copy it
  107. 'to the Clipboard and reinsert it whereever you want, VB
  108. 'automatically creates the Label1() Array. Simple
  109. '<Enter> will advance to the next Label or cycle back to
  110. 'the first one. You may also choose a label at random by
  111. 'clicking with your Mouse on it.
  112. 'Just make sure that you limit text input to fit the label
  113. 'size by setting the MaxLength variable or set the Label
  114. 'WordWrap variable to true.
  115. 'If you have use for it let me know.
  116. 'Peter Raddatz  : lupo@unix.infoserve.net
  117.  
  118. Private Sub Form_Load()
  119. set_t1 0                        'position TextBox
  120. End Sub
  121.  
  122. Private Sub L1_Click(x As Integer)
  123. tx = x
  124. set_t1 x                        'position TextBox
  125. End Sub
  126.  
  127. Private Sub T1_KeyPress(KeyAscii As Integer)
  128. Select Case KeyAscii
  129. Case 13
  130.     KeyAscii = 0
  131.     L1(tx) = T1                 'copy t1.text to label.caption
  132. If tx < L1.UBound Then
  133.     tx = tx + 1                 'incr. label count
  134. Else
  135.     tx = 0                      'or reset to 0
  136. End If
  137. set_t1 tx                       'position TextBox
  138. Case 8                          'do not print BS char
  139. Case Else                       'anything else show
  140. End Select
  141. End Sub
  142. Private Sub set_t1(nl As Integer)
  143.     T1.Left = L1(nl).Left       'define TextBox Coord.
  144.     T1.Top = L1(nl).Top
  145.     T1.Height = L1(nl).Height
  146.     T1.Width = L1(nl).Width
  147.     T1 = L1(nl)                 'copy l1.caption to t1.text
  148.     T1.SelStart = Len(T1)       'put the cursor at the end of text
  149. End Sub
  150.  
  151. Private Sub Command1_Click()
  152. End
  153. End Sub
  154.  
  155.